#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int n, m, tot;
int to[N], into[N];
bool vis[N];

void solve() {
	n = in, m = in;
	vector < vector < char > > s(n + 1, vector < char >(m + 1));
	vector < vector < int > > a(n + 1, vector < int >(m + 1)), id(n + 1, vector < int >(m + 1));
	
	rep(i, 1, n) {
		rep(j, 1, m) {
			char ch = getchar(); while(!isalpha(ch)) ch = getchar();
			s[i][j] = ch;
		}
	}
	tot = 0;
	rep(i, 1, n) rep(j, 1, m) a[i][j] = in, id[i][j] = ++tot;
	rep(i, 1, tot) to[i] = into[i] = vis[i] = 0;
	rep(i, 1, n) rep(j, 1, m) {
		int x = i, y = j;
		if(s[i][j] == 'u') x -= a[i][j];
		if(s[i][j] == 'd') x += a[i][j];
		if(s[i][j] == 'l') y -= a[i][j];
		if(s[i][j] == 'r') y += a[i][j];
		if(x <= 0 || x > n || y < 0 || y > m) to[id[i][j]] = 0;
		else to[id[i][j]] = id[x][y];
		into[to[id[i][j]]]++;
	}
	int p = 1; rep(i, 1, tot) if(into[i] == 0) { p = i; break; }
	while(!vis[p] && p) vis[p] = true, p = to[p];
	rep(i, 1, tot) if(!vis[i]) return puts("No"), void();
	puts("Yes");
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	for(int T = in; T; T--) solve(); return 0;
}
